<template>
	<view class="u-wrap">
		<!-- 搜索框 -->
		<u-search margin="20rpx 0rpx" :showAction="true" actionText="搜索" :animation="true"></u-search>
		<!-- 分类 -->
		<view class="tab-strickt">
			<u-tabs activeColor="#ff7670" name="cate_name" count="cate_count" :list="tabList" :is-scroll="true" v-model="current" @change="change"></u-tabs>
		</view>
		<!-- 瀑布流 -->
		<view class="">
			<u-waterfall v-model="flowList" ref="uWaterfall1">
				<template v-slot:left="{leftList}">
					<view class="demo-water-left" v-for="(item,index) in leftList" :key="index">
						<u-lazy-load threshold="-450" borderRadius="10" :image="item.image" :index="index"></u-lazy-load>
						<view class="demo-title">
							{{item.title}}
						</view>
						<view class="demo-price">
							{{item.price}}元
						</view>
						<view class="demo-tag">
							<view class="demo-tag-owner">
								自营
							</view>
							<view class="demo-tag-text">
								放心购
							</view>
						</view>
						<view class="demo-shop">
							{{item.shop}}
						</view>
						<u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)">
						</u-icon>
					</view>
				</template>
				<template v-slot:right="{rightList}">
					<view class="demo-water-right" v-for="(item,index) in rightList" :key="index">
						<u-lazy-load threshold="-450" borderRadius="10" :image="item.image" :index="index"></u-lazy-load>
						<view class="demo-title">
							{{item.title}}
						</view>
						<view class="demo-price">
							{{item.price}}元
						</view>
						<view class="demo-tag">
							<view class="demo-tag-owner">
								自营
							</view>
							<view class="demo-tag-text">
								放心购
							</view>
						</view>
						<view class="demo-shop">
							{{item.shop}}
						</view>
						<u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)">
						</u-icon>
					</view>
				</template>
			</u-waterfall>
			<u-loadmore bgColor="rgb(240,240,240)" :status="loadStatus" @loadmore="addRandomData"></u-loadmore>
		</view>
	</view>
</template>

<script setup>
	import{ ref } from 'vue';
	// 分类数据
	const tabList = ref([
		{
			cate_name:'全部'
		},
		{
			cate_name:'手机'
		},
		{
			cate_name:'电脑'
		},
		{
			cate_name:'衣服'
		},
		{
			cate_name:'鞋子'
		},
		{
			cate_name:'图书'
		},
		{
			cate_name:'时尚'
		},
		{
			cate_name:'手作'
		}
	])
	// 默认选中第一个分类
	const current = ref(0)
	
	// 瀑布流
	const flowList = ref([
		{
			price:75,
			title:'手机',
			image:'/static/11.jpg'
		},
		{
			price:385,
			title:'笔记本电脑',
			image:'/static/22.jpeg'
		},
		{
			price:784,
			title:'耳机',
			image:'/static/33.jpeg'
		},
		{
			price:7891,
			title:'手表',
			image:'/static/44.jpg'
		},
		{
			price:2341,
			title:'养生壶',
			image:'/static/66.jpeg'
		},
		{
			price:2342,
			title:'手表',
			image:'/static/55.jpg'
		},
		{
			price:2341,
			title:'手机',
			image:'/static/11.jpg'
		},
		{
			price:2342,
			title:'电脑',
			image:'/static/22.jpeg'
		}
	])
</script>

<style lang="scss">
	// 固定分类标签行在最顶部
	.tab-strickt{
		position: sticky;
		z-index: 99;
		top: 0;
		left: 0;
	}
	// 瀑布流
	.demo-water-left{
		border-radius: 8px;
		margin: 5px 0px 5px 5px;
		background-color: #fff;
		padding: 8px;
		position: relative;
	}
	.demo-water-right{
		border-radius: 8px;
		margin: 5px 5px 5px 0px;
		background-color: #fff;
		padding: 8px;
		position: relative;
	}
	.u-close{
		position: absolute;
		top: 32rpx;
		right: 32rpx;
	}
	.demo-image{
		width: 100%;
		border-radius: 4px;
	}
	.demo-title{
		font-size: 30rpx;
		margin-top: 5px;
		color: $u-main-color;
	}
	.demo-tag{
		display: flex;
		margin-top: 5px;
	}
	.demo-tag-owner{
		background-color: $u-type-error;
		color: #fff;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}
	.demo-tag-text{
		border: 1px solid $u-type-primary;
		color: $u-type-primary;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}
	.demo-price{
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
	}
	.demo-shop{
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}
</style>
